package com.ruoyi.yh.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yh.domain.YhBloodImage;
import com.ruoyi.yh.service.IYhBloodImageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 性状图片Controller
 * 
 * @author ruoyi
 * @date 2022-03-14
 */
@RestController
@RequestMapping("/yh/bloodimage")
public class YhBloodImageController extends BaseController
{
    @Autowired
    private IYhBloodImageService yhBloodImageService;

    /**
     * 查询性状图片列表
     */
    @PreAuthorize("@ss.hasPermi('yh:bloodimage:list')")
    @GetMapping("/list")
    public TableDataInfo list(YhBloodImage yhBloodImage)
    {
        startPage();
        List<YhBloodImage> list = yhBloodImageService.selectYhBloodImageList(yhBloodImage);
        return getDataTable(list);
    }

    /**
     * 导出性状图片列表
     */
    @PreAuthorize("@ss.hasPermi('yh:bloodimage:export')")
    @Log(title = "性状图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YhBloodImage yhBloodImage)
    {
        List<YhBloodImage> list = yhBloodImageService.selectYhBloodImageList(yhBloodImage);
        ExcelUtil<YhBloodImage> util = new ExcelUtil<YhBloodImage>(YhBloodImage.class);
        util.exportExcel(response, list, "性状图片数据");
    }

    /**
     * 获取性状图片详细信息
     */
    @PreAuthorize("@ss.hasPermi('yh:bloodimage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(yhBloodImageService.selectYhBloodImageById(id));
    }

    /**
     * 新增性状图片
     */
    @PreAuthorize("@ss.hasPermi('yh:bloodimage:add')")
    @Log(title = "性状图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YhBloodImage yhBloodImage)
    {
        return toAjax(yhBloodImageService.insertYhBloodImage(yhBloodImage));
    }

    /**
     * 修改性状图片
     */
    @PreAuthorize("@ss.hasPermi('yh:bloodimage:edit')")
    @Log(title = "性状图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YhBloodImage yhBloodImage)
    {
        return toAjax(yhBloodImageService.updateYhBloodImage(yhBloodImage));
    }

    /**
     * 删除性状图片
     */
    @PreAuthorize("@ss.hasPermi('yh:bloodimage:remove')")
    @Log(title = "性状图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yhBloodImageService.deleteYhBloodImageByIds(ids));
    }
}
